<?php
include_once('global.php');
//$db->query("INSERT INTO `ip` (`ipid`, `ip`) VALUES (NULL,'".$db->get_IP()."')");
$query=$db->query("select ip from ip where ip='".$db->get_IP()."'");
$row = $db->fetch_array($query);
if($row)
{
	$db->get_show_msg("http://www.bbangnet.com/","非法IP(如有疑问请联系我们)",10000);
}
if(isset($_POST['into_add'])){
	unset($_POST['into_add']);
	$query = $db->query("select ip,date_time from p_newsbase where ip='".$db->get_IP()."' ORDER BY  `p_newsbase`.`id` DESC LIMIT 0 , 1");
	$row = $db->fetch_array($query);
	$cha=$db->get_time()-$row[date_time];
    /*if($db->get_IP()==$row[ip]&&$cha<=400)
	{
		 $db->get_show_msg("http://www.bbangnet.com/","您添加太快，请过60秒后添加",5);
		
	}else {*/
		$db->query("INSERT INTO `p_newsbase` (`keyword`, `id`, `cid`, `title`,  `date_time`,`ip`) " .
	     		"VALUES ('$_POST[keyword]',NULL, '$_GET[id]', '$_POST[title]',  '".$db->get_time()."','".$db->get_IP()."')");
	    $last_id=$db->insert_id();
	    $db->query("INSERT INTO `p_newscontent` (`nid`, `diu_time`, `diu_place`, `phone`, `name`, `qq`, `other`) " .
		"VALUES ($last_id, '$_POST[diu_time]', '$_POST[diu_place]', '$_POST[phone]', '$_POST[name]', '$_POST[qq]', '$_POST[other]')"); 
	 $db->get_show_msg("http://www.bbangnet.com/view.php?id=".$last_id."","添加成功");
	//}
}
 $smarty->display("add_test.htm");
?>
